package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.WeiXinService;
import com.yixun.qfbao.apidto.GetWxModelSetListReqDto;
import com.yixun.qfbao.apidto.GetWxModelSetListResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetWxModelSetListReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GetWxMsgModelHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetWxMsgModelHander.class);
    @Autowired
    private WeiXinService weiXinService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BaseResponseDTO<GetWxModelSetListResDto> res = new BaseResponseDTO<GetWxModelSetListResDto>();
        GetWxModelSetListResDto resDto = new GetWxModelSetListResDto();
        GetWxModelSetListReqVo reqVo = (GetWxModelSetListReqVo)reqDto;
        GetWxModelSetListReqDto getModelReqDto = reqVo.getParams();
        try {
            resDto = weiXinService.getWxMsgModelList(getModelReqDto);
            res.setResult(resDto.getResult());
            res.setResData(resDto);
        } catch (Exception e) {
            logger.error("GetWxMsgModelHander error: {}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setErrorMsg("获取微信模板消息列表失败");
        }
        return res;
    }
}
